<%--
  Created by IntelliJ IDEA.
  User: yuzhihao
  Date: 2022/3/15
  Time: 19:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/regist.css">
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/image/smallLogo.svg" type="image/x-icon">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.6.0.min.js"></script>

</head>
<body>

<div class="box">
    <div class="left"></div>
    <div class="right">
        <h4>注&nbsp;&nbsp;&nbsp;&nbsp;册</h4>
<%--        ${pageContext.request.contextPath}/member/regist--%>
        <form action="${pageContext.request.contextPath}/member/regist" method="post">
            <input class="telephone" type="text" placeholder="手机号" name="memberTelno">
            <input class="username" type="text" placeholder="用户名" name="memberName">
            <input class="password" type="password" placeholder="密码" name="memberPwd">
            <input class="repassword" type="password" placeholder="确认密码" name="member2Pwd">
            <input class="submit" type="submit" value="注册">
            <br>
            <span style="color: orangered">${regist}</span>
            <br>
        </form>
    </div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/crypto-js/crypto-js.js"></script>
<script>
    $(".submit").click(function () {
        const KEY = CryptoJS.enc.Utf8.parse("1234567890123456");
        const IV = CryptoJS.enc.Utf8.parse('1234567890123456');
        let key = KEY
        let iv = IV

        var pwd = $(".password").val();
        let pwdEncode = CryptoJS.enc.Utf8.parse(pwd);
        var encryptedPassword = CryptoJS.AES.encrypt(pwdEncode, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.ZeroPadding
        })

        var encryptPasswordBase64 =  CryptoJS.enc.Base64.stringify(encryptedPassword.ciphertext);
        $(".password").val(encryptPasswordBase64);

        var repwd = $(".repassword").val();
        let repwdEncode = CryptoJS.enc.Utf8.parse(repwd);
        var reencryptedPassword = CryptoJS.AES.encrypt(repwdEncode, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.ZeroPadding
        })

        var reencryptPasswordBase64 =  CryptoJS.enc.Base64.stringify(reencryptedPassword.ciphertext);
        $(".repassword").val(reencryptPasswordBase64);
    })
</script>

<script src="${pageContext.request.contextPath}/js/regist.js"></script>

</body>
</html>
